#pragma once

#include "frontend/token.h"

namespace mspc {

class Lexer {

private:
    std::string input_;
    std::string filename_;
    size_t position_;
    int line_;
    int column_;

    std::unordered_map<std::string, TokenType> keywords_;
    std::unordered_map<std::string, TokenType> typewords_;

public:
    static void print_tokens(const std::vector<Token>& tokens);
    Lexer(const std::string& input, const std::string& filename = std::string());

    TokenContainer tokenize();
    const std::string& filename() const;

private:
    Token read_next_token();
    Token read_identifier();
    Token read_string();
    Token read_number();
    Token make_token(TokenType type, const std::string& value);
    Token make_error_token(const std::string& message);
    void skip_whitespace();
    void skip_line_comment();
    void skip_block_comment();
    char peek() const;
    char advance();
    bool is_at_end() const;
};
} // namespace mspc
